package com.example.gallery;

import java.util.ArrayList;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

import com.example.board.R;


public class AlbumList extends ListActivity implements OnItemClickListener {
	
	static final String TAG ="AlbumList";
	ListView listView;
	ArrayList<AlbumDTO> list;
	String folder = ""; 
			
			
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.albumlist);
		listView = (ListView) findViewById(android.R.id.list);
		
		listView.setOnItemClickListener(this);
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		Log.i(TAG, "onResume");
		
		Common common = new Common();
		
		list = new ArrayList<AlbumDTO>();
		list = common.getAlbumList();
		
		AlbumListAdapter adapter = new AlbumListAdapter(this, R.layout.album_row, list);
		listView.setAdapter(adapter);
	}
	
	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
		AlbumDTO dto = (AlbumDTO) parent.getAdapter().getItem(position);
		folder = dto.getA_name();
		Intent intent = new Intent(this, ImageList.class);
		intent.putExtra("folder", folder);
		startActivity(intent);
//		finish();
		Log.i(TAG, "앨범명 : "+ folder);
	}

	@Override
	protected void onPause() {
		super.onPause();
	}

	@Override
	protected void onRestart() {
		super.onRestart();
	}

	@Override
	protected void onStart() {
		super.onStart();
	}

	@Override
	protected void onStop() {
		super.onStop();
	}

	
}
